/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * <p>This is a subclass of XREEvent that represents the "onStreamProgress" event. It defines some properties specific
 * to this event. Note that values of all custom properties are actually stored in the XREEvent#params map.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
@SuppressWarnings("boxing")
public class XREVideoStreamProgressEvent extends XREResourceEvent {

    /**
     * <p>Represents the name of the "on stream progress" event. This is a string constant used by the user when setting
     * the name of the event.</p>
     */
    public static final String ON_STREAM_PROGRESS_COMPLETE_EVENT_NAME = "onStreamProgress";

    /**
     * <p>Represents the name used to retrieve the time parameter.</p>
     */
    private static final String TIME = "time";

    /**
     * <p>Represents the name used to retrieve the duration parameter.</p>
     */
    private static final String DURATION = "duration";

    /**
     * <p>Creates new instance of {@link XREVideoStreamProgressEvent} class.</p>
     */
    public XREVideoStreamProgressEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the current playback position, in milliseconds.</p>
     *
     * @return the current playback position, in milliseconds
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getTime() {
        return getTypedParam(TIME, Double.class);
    }

    /**
     * <p>Sets the current playback position, in milliseconds.</p>
     *
     * @param time the current playback position, in milliseconds
     *
     * @throws IllegalStateException if params is null
     */
    public void setTime(double time) {
        setParam(TIME, time);
    }

    /**
     * <p>Retrieves the duration of the video, in milliseconds.</p>
     *
     * @return the duration of the video, in milliseconds
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getDuration() {
        return getTypedParam(DURATION, Double.class);
    }

    /**
     * <p>Sets the duration of the video, in milliseconds.</p>
     *
     * @param duration the duration of the video, in milliseconds
     *
     * @throws IllegalStateException if params is null
     */
    public void setDuration(double duration) {
        setParam(DURATION, duration);
    }
}

